<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" style="height: 100%">
<body class="body_hei edit">
<div th:replace="include/head.html::html"></div>
<div class="layui-form" lay-filter="form" id="layuiadmin-form-useradmin"
     style="padding: 20px 0 0 0;background-color: #FFFFFF;height: 100%">
    <input type="hidden" name="oid" />
    <input type="hidden" name="type" />
    <div class="layui-form-item">
        <label class="layui-form-label">标题:</label>
        <div class="layui-input-inline" style="width: 70%;">
            <input type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off"
                   class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-inline" style="width: 80%">
            <textarea id="demo" name="content" style="display: none;" ></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <input class="layui-btn" type="button" lay-submit lay-filter="submit" id="submit" value="确认">
    </div>
</div>
<script type="text/javascript" th:inline="javascript">
    layui.use(['jquery', 'form', 'layedit'], function () {
        var $ = layui.$;
        var layedit = layui.layedit;
        var form = layui.form;
        var id ;
        $.post("helpCenter/getBean", {oid:[[${oid}]]}, function (res) {
            if (res.code === 0) {
                form.val('form', res.data);
                id = layedit_initialize(layedit,'demo');
            } else {
                top.layer.msg(res.msg);
            }
        });

        form.on('submit(submit)', function (data) {
            var field = data.field;
            field.content = layedit.getContent(id);
            $.post("helpCenter/saveOrUpdateBean", field, function (res) {
                if (res.code === 0) {
                    top.layer.msg(res.msg);
                    window.location.reload(true);
                } else {
                    top.layer.msg(res.msg);
                }
            });
        });
    });
</script>
</body>
</html>